

#ifndef DEMO_H
#define DEMO_H

#include "../xEngine/D3d11App.h"
#include "../xEngine/Effect.h"
#include "../xEngine/Mesh.h"
#include "../xEngine/ConstantBuffer.h"
#include "../xEngine/Camera.h"
#include "../xEngine/Entity.h"
#include "../xEngine/RenderTexture.h"

struct Transform
{
	XMMATRIX mWorld;
	XMMATRIX mWorldViewProj;
	XMVECTOR mLightDirection;
};

struct TransformShadow
{
	XMMATRIX mWorldViewProj;
	XMMATRIX mLightWorldViewProj;
};

class Demo: public D3d11App
{
public:
	Demo(HINSTANCE hInstance);
	~Demo();

	void Init();			// Override
	void Draw();			// Override
	void Update(float dt);	// Override
	LRESULT MsgProc(UINT msg, WPARAM wParam, LPARAM lParam);	// Override

private:
	typedef D3d11App super;
	
	Camera mCamera;
	Camera mShadowLight;

	FLOAT mShadowLightRotDeg;

	Effect* mpDirLightFx;
	Effect* mpDrawShadowMapFx;
	Effect* mpRenderWithShadowFx;

	ConstantBuffer* mpConstBuf;
	RenderTexture* mpShadowMap;
	
	POINT mOldMousePos;
	
	Entity mBuilding;
	Entity mFloor;
	std::vector<Entity*> mEntities;

	Entity mAxes;
	
	Entity mTextureQuad;

	Mesh* mpShadowMapQuad;

	void InitFloor();
	void InitSpaceship();
	void InitTextureQuad();
	void InitAxes();
	void InitShadowMapQuad();

	void DrawEntity(Entity &entity);
	void DrawEntity(Entity &entity, Camera &camera);
	void DrawEntities();
	void DrawEntityWithShadow(Entity &entity);
	void DrawEntityWithShadow(Entity &entity, Camera &camera);

	void DrawCameraQuad(bool shadowMap);

};

#endif